/**
 * Bestpay.com.cn Inc.
 * Copyright (c) 2011-2020 All Rights Reserved.
 */
package com.suxiaoxiao.springbootlearn.designpattern.proxypattern.proxy;

import com.suxiaoxiao.springbootlearn.designpattern.proxypattern.pojo.PersonBean;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 查看自己信息的代理类
 * 自己不允许修改自己的评分
 * 允许修改自己除评分外其他信息
 * 允许查看自己信息
 *
 * @author zhaorongzhang
 * @version OwnerInvocationHandler.java, v 0.1 2020/1/12 11:52 下午 zhaorongzhang Exp $$
 */
public class OwnerInvocationHandler extends InvokeMethodConstant {

    public OwnerInvocationHandler(PersonBean person) {
        this.person = person;
    }

    @Override
    protected Object getMethodHandler(Method method, Object[] args) throws InvocationTargetException, IllegalAccessException {
        return pass(method, args);
    }

    @Override
    protected Object setRatingMethodHandler(Method method, Object[] args) throws InvocationTargetException, IllegalAccessException {
        return notPass();
    }

    @Override
    protected Object setMethodHandler(Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
        return pass(method, args);
    }

}